package com.example.educationalsystem.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.educationalsystem.entity.Course;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.educationalsystem.entity.Vo.CourseVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author zpc
 * @since 2022-12-02
 */
@Repository
public interface ICourseMapper extends BaseMapper<Course> {
    @Select("<script>" +
            "select a.*,b.teacher_name,b.teacher_sex,b.teacher_phone,c.classroom_ridgepole,c.classroom_type\n" +
            "from course a  \n" +
            "left join teacher b on a.teacher_id=b.teacher_id \n" +
            "left join classroom c on a.classroom_id=c.classroom_id \n" +
            "</script>")
    List<CourseVo> getAllCourse();
    @Select("<script>" +
            "select a.*,b.teacher_name,b.teacher_sex,b.teacher_phone,c.classroom_ridgepole,c.classroom_type\n" +
            "from course a  \n" +
            "left join teacher b on a.teacher_id=b.teacher_id \n" +
            "left join classroom c on a.classroom_id=c.classroom_id where 1=1\n" +
            "<if test='ew != null'>" +
            " AND ${ew.SqlSegment}" +
            "</if>"
            + "</script>")
    Page<CourseVo> getCoursePage(Page<CourseVo> page, @Param("ew") Wrapper wrapper);
}
